package com.ai.ai.config;

import com.ai.ai.filter.HttpCorsFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 过滤器配置类
 * @author Scott Soong
 **/
@Configuration
public class FilterConfig {

    /**
     * 注册非上传文件的Http请求和响应增加Wrapper过滤器
     */
    @Bean
    public FilterRegistrationBean<HttpCorsFilter> httpCorsFilter() {
        FilterRegistrationBean<HttpCorsFilter> registration = new FilterRegistrationBean<>();
        registration.setFilter(new HttpCorsFilter());
        registration.addUrlPatterns("/*");
        registration.setName("httpCorsFilter");
        return registration;
    }
}